package com.wmcsk;
import android.content.Context;
import com.wmcsk.dl.util.LogUtils;
import com.wmcsk.interfaces.InitResultListener;
import com.wmcsk.interfaces.KuaiyanDataStatisticsInterface;
/**
 * Created by wm on 2018/5/17.
 */
public class KuaiyanDataStatisticsSdk implements KuaiyanDataStatisticsInterface{
    private static KuaiyanDataStatisticsSdk kuaiyanDataStatisticsSdk;
    public static final String ERROR_TAG = "KuaiyanDataStatisticsSdk";
    private KuaiyanDataStatisticsSdk(){

    }
    public static KuaiyanDataStatisticsSdk getInstance(){
        if(kuaiyanDataStatisticsSdk == null){
            synchronized (KuaiyanSdk.class){
                if(kuaiyanDataStatisticsSdk == null){
                    kuaiyanDataStatisticsSdk = new KuaiyanDataStatisticsSdk();
                }
            }
        }
        return kuaiyanDataStatisticsSdk;
    }

    private KuaiyanDataStatisticsInterface kuaiyanDataStatisticsInterface;
    public void initKYDataStatisticsSdkInterface(KuaiyanDataStatisticsInterface kuaiyanDataStatisticsInterface){
        this.kuaiyanDataStatisticsInterface = kuaiyanDataStatisticsInterface;
    }
    @Override
    public String getVersion() {
        if(kuaiyanDataStatisticsInterface == null){
            LogUtils.getNewInstance(ERROR_TAG).eob("please wait sdkinit init complate");
            return "null";
        }
        return kuaiyanDataStatisticsInterface.getVersion();
    }

    @Override
    public void init(Context context, InitResultListener initResultListener) {
        if(kuaiyanDataStatisticsInterface == null) {
            LogUtils.getNewInstance(ERROR_TAG).eob("please wait sdkinit init complate");
            if(initResultListener!=null){
                initResultListener.initResult(-10);
            }
            return;
        }
        kuaiyanDataStatisticsInterface.init(context,initResultListener);
    }

    @Override
    public String getSdkInfo() {
        if(kuaiyanDataStatisticsInterface == null){
            LogUtils.getNewInstance(ERROR_TAG).eob("please wait sdkinit init complate");
            return "null";
        }
        return kuaiyanDataStatisticsInterface.getSdkInfo();
    }

    @Override
    public void setExtentionInfoFroKuaiyan(String userInfo, String extionKey, String extentionInfo) {
        if(kuaiyanDataStatisticsInterface == null){
            LogUtils.getNewInstance(ERROR_TAG).eob("please wait sdkinit init complate");
            return ;
        }
        kuaiyanDataStatisticsInterface.setExtentionInfoFroKuaiyan(userInfo,extionKey,extentionInfo);
    }

    @Override
    public void setExtentionInfo(String extentionInfo) {
        if(kuaiyanDataStatisticsInterface == null){
            LogUtils.getNewInstance(ERROR_TAG).eob("please wait sdkinit init complate");
            return ;
        }
        kuaiyanDataStatisticsInterface.setExtentionInfo(extentionInfo);
    }
}
